<?php

namespace IDock\Insurance\AICS\Request;

use Exception;
use IDock\Insurance\AICS\Response\UploadFileResponse;
use IDock\Visitor\UploadFileVisitor;

class UploadFileRequest extends AllAICSRequest
{
    public $code = 'newImageUpService';

    public $envelopeName = 'new:newImageUpAH';

    public $inLog = false;

    protected $response = UploadFileResponse::class;

    protected $urlTip = '影像资料上传';

    /**
     * @var UploadFileVisitor $visitor
     */
    protected $visitor;

    /**
     * @return array
     * @throws Exception
     */
    public function generate(): array
    {
        $fileList = $this->visitor->getFileList();
        $file = $fileList[0];
        return [
            'requestBase' => [
                'rack' => $this->visitor->argc['vin'] ?? '',
                'deptCode' => $this->visitor->argc['CDptCde'] ?? '0580',
                'picTureName' => basename($file['url']),
                'encoderBase' => base64_encode(file_get_contents($file['url'])),
                'oprCde' => $this->visitor->argc['COprCde'] ?? '',
                'Imgtype' => '',
            ],
        ];
    }
}
